// +----------------------------------------------------------------------
// | Project:   Android-Commons
// +----------------------------------------------------------------------
// | CreateTime: 12/10/2015 13:57 下午
// +----------------------------------------------------------------------
// | Author:     xab(xab@xabad.cn)
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
package cn.xabad.commons.sample.interactors;

import cn.xabad.commons.converter.GsonCallback;
import cn.xabad.commons.sample.model.StudentInfo;
import javax.inject.Inject;

import cn.xabad.commons.converter.StringCallback;
import cn.xabad.commons.sample.http.IHttpLogin;
import cn.xabad.commons.sample.http.RestAdapter;
import retrofit.Call;

/**
 * DESC   :
 * AUTHOR : Xabad
 */
public class MainInteractor {

    @Inject
    public MainInteractor() {
    }


    public void regist(String username, String nickname, String password, String figureUrl,
                       StringCallback callback) {
        IHttpLogin httpLogin = RestAdapter.getStringInstance()
                                          .create(IHttpLogin.class);
        Call<String> call = httpLogin.regist(username, nickname, password, figureUrl);
        call.enqueue(callback);
    }


    public void login(String username, String password, StringCallback callback) {
        IHttpLogin httpLogin = RestAdapter.getStringInstance()
                                          .create(IHttpLogin.class);
        Call<String> call = httpLogin.login(username, password);
        call.enqueue(callback);
    }


    public void userme(String accessToken, GsonCallback<StudentInfo> callback) {
        IHttpLogin httpLogin = RestAdapter.getStringInstance()
                                          .create(IHttpLogin.class);
        Call<StudentInfo> call = httpLogin.getStudentInfo(accessToken);
        call.enqueue(callback);
    }


}
